<#assign ctx=request.contextPath />
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>自定义标签添加</title>
    <script src="${ctx}/js/jquery.min.js"></script>
    <script src="${ctx}/layui/layui.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">
    <style>
        .layui-form-item {
            width: 500px;
        }
    </style>
</head>
<body>

<div class="site-text site-block" style=" border:1px solid #ccc; padding:20px; margin:20px;">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">标签名</label>
            <div class="layui-input-block">
                <input type="text" name="tag" lay-verify="required" class="layui-input"/>
            </div>
        </div>
        <#--<div class="layui-form-item" id="div_isPublic">
            <label class="layui-form-label">是否公开</label>
            <div class="layui-input-block">
                <input type="checkbox" id="isPublic" name="isPublic" lay-skin="switch" lay-text="ON|OFF" checked>
            </div>
        </div>-->

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                <#--<input type="text" name="addCode" lay-verify="required" class="layui-input"/>-->
                    <textarea class="layui-textarea" name="ps" style="width: 390px;"></textarea>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
            <#--<a onclick="window.history.go(-1);" class="layui-btn layui-btn-primary">返回</a>-->
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formDemo">添加</button>
            </div>
        </div>
    </form>
</div>


<script>

    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        var form = layui.form;
        form.on('submit(formDemo)',
            function (data) {
                var obj = data.field;
                console.log(obj);
                $.ajax({
                    url: "${ctx}/addCustomTag",
                    type: "post",
                    data: obj,
                    success: function (res) {
                        if (res.status == 0) {
                            layer.msg(res.msg, {icon: 6, time: 600}, function () {
                                location.href = '${ctx}/customTagList'
                            });
                        } else {
                            layer.msg(res.msg, {icon: 5})
                        }
                    }
                });
                return false;
            });
    });

</script>
</body>
</html>
